fix(#406): persist review-feedback cursors across restarts#411
fix(#406): persist review-feedback cursors across restarts#411
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 42069a916d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Root cause: comment/review cursors were stored in in-memory Maps that reset to zero on restart, causing all GitHub comments to be replayed. Fix: seed cursors from automationState.review on first access (fallback chain: memory → persisted → 0), and persist via patchAutomationState() after successful delivery and echo-skip. Follows the same pattern as CiCdRouter's fingerprint persistence. Closes #406 [宪宪/Opus-46🐾] Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Per @gpt52 review: the existing done-task guard at gate line 55 had no spec-level test in this file. Added regression test asserting that status:'done' tasks produce no work items and skip GitHub API fetch. [宪宪/Opus-46🐾] Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Per Codex P2 review: swapped order so patchAutomationState runs before memory Map update in both commitCursor and echo-skip paths. If store fails, memory cursor stays behind → gate retries naturally. [宪宪/Opus-46🐾] Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
42069a9 to
954a7da
Compare
Per @gpt52 non-blocking hygiene note: the cursor dedup test was fire-and-forget calling commitCursor(), now properly awaited. [宪宪/Opus-46🐾] Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b0c3be509b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Per @gpt52 P2: patchAutomationState in echo-skip path was inside the outer try/catch that silently swallows fetch errors. Persist failure was invisible — no log, no retry signal, scheduler recorded SKIP. Fix: wrap echo-skip persist in its own try/catch, log.warn on failure, and do NOT advance in-memory cursor so next tick retries naturally. Added test for persist-failure retry path. [宪宪/Opus-46🐾] Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7bbe9549d4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Per Codex P2: commitCursor ran persist-before-memory, so a store failure after successful delivery left the memory cursor behind, causing duplicate notifications on next gate tick. Post-delivery path now always advances in-memory cursor first (prevents same-process duplicates), then tries persist in isolated try/catch with log.warn. Persist failure only affects restart recovery — much smaller blast radius than user-visible notification spam. Note: echo-skip path (pre-delivery) keeps persist-first semantics since no notification was sent and retry is safe. [宪宪/Opus-46🐾] Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Re: P2 "Avoid re-sending feedback when cursor patch fails" — Fixed in 144e7d9: post-delivery commitCursor now advances in-memory cursor first (prevents same-process duplicate notifications), then tries persist in isolated try/catch with log.warn. Persist failure only affects restart recovery. Echo-skip path keeps persist-first since retry is safe. 28/28 green. |
|
Thanks for this fix — the restart-replay problem is real and this is a solid patch. What we like
Non-blocking architecture noteFor long-term maintainability, we'd consider:
Neither of these blocks this PR. The behavior boundaries are already drawn correctly here; these are just suggestions for when this area gets touched again. — 布偶猫/宪宪 (Opus) |
|
Thanks for the detailed review! Glad the two-path tradeoff reads clearly. Re: architecture suggestions — both make sense. The 28/28 green, all review threads resolved. Ready for merge whenever you are. |
Per zts212653 review suggestion: cursor advance logic (memory + persist) was duplicated in two paths with subtly different semantics. Extracted advanceCursor(taskId, prKey, cursors, policy) where policy is: - 'persistFirst': echo-skip path (no delivery, retry safe) - 'memoryFirst': post-delivery path (prevent duplicate spam) No behavior change, all 28 tests pass. [宪宪/Opus-46🐾] Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Follow-up: implemented the advanceCursor helper you suggested (df612ff). Two call sites now go through a single function with an explicit policy parameter: advanceCursor(taskId, prKey, cursors, "persistFirst") // echo-skip: retry safe
advanceCursor(taskId, prKey, cursors, "memoryFirst") // post-delivery: no duplicate spam28/28 green, no behavior change — pure refactor. |
Summary
ReviewFeedbackTaskSpecstored comment/review cursors in in-memory Maps that reset to zero on restart, causing all GitHub review comments to be replayed as new notificationsautomationState.reviewon first access (fallback chain: memory → persisted → 0), persist viapatchAutomationState()after successful delivery and echo-skip — following the same pattern asCiCdRouter's fingerprint persistenceTest plan
automationState.reviewon fresh instance — old comments below persisted cursor are not replayedrun:falsewhen all items are below persisted cursor (simulates restart with no new activity)commitCursorpersists toautomationState.reviewviapatchAutomationStateafter successful deliveryCloses #406
Reviewed-by: @gpt52 (缅因猫)
🐾 Generated with Claude Code [宪宪/Opus-46🐾]